home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Scripts / PickInit.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  8.9 KB  |  228 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import copy_reg
  6. import types
  7. GlobalModulesCache = None
  8. GlobalFunctionsCache = None
  9. GlobalCFunctionsCache = None
  10.  
  11. def GetGlobalsAux():
  12.     import sys
  13.     
  14.     try:
  15.         1 + ''
  16.     except:
  17.         frame = sys.exc_info()[2].tb_frame.f_back
  18.  
  19.     while frame:
  20.         globs = frame.f_globals
  21.         frame = frame.f_back
  22.     return globs
  23.  
  24.  
  25. def GetGlobalsAux2(req_type):
  26.     g = GetGlobalsAux()
  27.     elems = []
  28.     for i in g.items():
  29.         pass
  30.     
  31.     return elems
  32.  
  33.  
  34. def ConstSound(sound_name, sound_file, volume, base_volume, min_distance, max_distance, scale, send_notify):
  35.     s = Bladex.CreateSound(sound_file, sound_name)
  36.     if not s:
  37.         return None
  38.     
  39.     s.Volume = volume
  40.     s.BaseVolume = base_volume
  41.     s.MinDistance = min_distance
  42.     s.MaxDistance = max_distance
  43.     s.Scale = scale
  44.     s.SendNotify = send_notify
  45.     return s
  46.  
  47.  
  48. def RedSound(s):
  49.     return (ConstSound, (s.Name, '', s.Volume, s.BaseVolume, s.MinDistance, s.MaxDistance, s.Scale, s.SendNotify))
  50.  
  51.  
  52. def RegisterPickSound():
  53.     gmadlig = Bladex.CreateSound('../../sounds/golpe-madera-mediana.wav', 'GolpeMaderaMediana')
  54.     copy_reg.pickle(type(gmadlig), RedSound, ConstSound)
  55.  
  56.  
  57. def ConstEntity(ent_name):
  58.     e = Bladex.GetEntity(ent_name)
  59.     return e
  60.  
  61.  
  62. def RedEntity(e):
  63.     if e:
  64.         
  65.         try:
  66.             return (ConstEntity, (e.Name,))
  67.         except:
  68.             print 'PickInit.RedEntity() can not get entity name'
  69.             return (ConstEntity, ('Invalid Entity',))
  70.  
  71.     
  72.     return (ConstEntity, ('Invalid Entity',))
  73.  
  74.  
  75. def RegisterPickEntity():
  76.     gmadlig = Bladex.GetEntity(0)
  77.     copy_reg.pickle(type(gmadlig), RedEntity, ConstEntity)
  78.  
  79.  
  80. def FindFunctionAux(module, fun_name):
  81.     if module.__dict__.has_key(fun_name):
  82.         return module.__dict__[fun_name]
  83.     
  84.     return None
  85.  
  86.  
  87. def ConstFunction(fun_name, lib_name):
  88.     funcs = GetGlobalsAux2(types.FunctionType)
  89.     for i in funcs:
  90.         pass
  91.     
  92.     global_mods = GetGlobalsAux2(types.ModuleType)
  93.     for i in global_mods:
  94.         pass
  95.     
  96.     for i in global_mods:
  97.         func = FindFunctionAux(i[1], fun_name)
  98.     
  99.     print "Warning, can't find global function '", fun_name, "'", lib_name, "'"
  100.     return None
  101.  
  102.  
  103. def RedFunction(f):
  104.     import GameStateAux
  105.     s = GameStateAux.GetFunctionFile(f)
  106.     return (ConstFunction, (f.func_name, s))
  107.  
  108.  
  109. def RegisterPickFunction():
  110.     import types
  111.     copy_reg.pickle(types.FunctionType, RedFunction, ConstFunction)
  112.  
  113.  
  114. def ConstMethod(obj_id, method_name):
  115.     import types
  116.     import ObjStore
  117.     
  118.     try:
  119.         obj = ObjStore.ObjectsStore[obj_id]
  120.         assign_func = eval('obj.' + method_name)
  121.         return assign_func
  122.     except Exception:
  123.         exc = None
  124.         print 'PickInit.ConstMethod() can not find method', obj_id, method_name
  125.         if ObjStore.ObjectsStore.has_key(obj_id):
  126.             print 'Object ', obj_id, 'exists. -> ', ObjStore.ObjectsStore[obj_id]
  127.         else:
  128.             print 'Object ', obj_id, 'does not exist.'
  129.             print ObjStore.ObjectsStore
  130.         print 'Exception', exc
  131.         return None
  132.  
  133.  
  134.  
  135. def RedMethod(f):
  136.     
  137.     try:
  138.         return (ConstMethod, (f.im_class.persistent_id(f.im_self), f.im_func.func_name))
  139.     except:
  140.         print 'PickInit.RedMethod() can not register method', f
  141.         return (ConstMethod, (None, None))
  142.  
  143.  
  144.  
  145. def RegisterPickMethod():
  146.     import types
  147.     copy_reg.pickle(types.MethodType, RedMethod, ConstMethod)
  148.  
  149.  
  150. def ConstCFunction(fun_name, ent_name):
  151.     print "ConstCFunction: '", fun_name, "','", ent_name, "'"
  152.     if ent_name:
  153.         import Bladex
  154.         ent = Bladex.GetEntity(ent_name)
  155.         if ent:
  156.             assign_func = eval('ent.' + fun_name)
  157.             return assign_func
  158.         else:
  159.             print 'Can not find entity', ent_name
  160.             return None
  161.     
  162.     funcs = GetGlobalsAux2(types.BuiltinFunctionType)
  163.     for i in funcs:
  164.         pass
  165.     
  166.     import Bladex
  167.     import Traps_C
  168.     import B3DLib
  169.     mods = (Bladex, B3DLib, Traps_C)
  170.     for i in mods:
  171.         func = FindFunctionAux(i, fun_name)
  172.     
  173.     global_mods = GetGlobalsAux2(types.ModuleType)
  174.     for i in global_mods:
  175.         pass
  176.     
  177.     print "Warning, can't find global function", fun_name
  178.     return None
  179.  
  180.  
  181. def RedCFunction(f):
  182.     if f.__self__:
  183.         return (ConstCFunction, (f.__name__, f.__self__.Name))
  184.     else:
  185.         return (ConstCFunction, (f.__name__, None))
  186.  
  187.  
  188. def RegisterPickCFunction():
  189.     import types
  190.     copy_reg.pickle(types.BuiltinFunctionType, RedCFunction, ConstCFunction)
  191.  
  192.  
  193. def ConstSector(sec_idx):
  194.     e = Bladex.GetSector(sec_idx)
  195.     return e
  196.  
  197.  
  198. def RedSector(s):
  199.     return (ConstSector, (s.Index,))
  200.  
  201.  
  202. def RegisterPickSector():
  203.     gmadlig = Bladex.GetSector(0)
  204.     if not gmadlig:
  205.         print 'ERROR in RegisterPickSector()'
  206.         return None
  207.     
  208.     copy_reg.pickle(type(gmadlig), RedSector, ConstSector)
  209.  
  210.  
  211. def ClearCaches():
  212.     global GlobalModulesCache, GlobalFunctionsCache, GlobalCFunctionsCache
  213.     GlobalModulesCache = None
  214.     GlobalFunctionsCache = None
  215.     GlobalCFunctionsCache = None
  216.  
  217.  
  218. def Init():
  219.     ClearCaches()
  220.     RegisterPickSound()
  221.     RegisterPickEntity()
  222.     RegisterPickFunction()
  223.     RegisterPickSector()
  224.     RegisterPickMethod()
  225.     RegisterPickCFunction()
  226.     print 'Executed PickInit.Init()'
  227.  
  228.